import request from '../request';

/**
 * AI对话相关API接口
 */

// 获取历史对话消息
export const fetchChatHistoryList = (data, config = {}) => {
  return request.post('/appAgent/conversationMessage/getPageList', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 获取语音识别的token
export const fetchChatAudioToken = (data, config = {}) => {
  return request.post('/appAgent/aiDialogueHistory/getBaiduToken', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 清除chatGPT的上下文内容
export const fetchChatClearMessage = (data, config = {}) => {
  return request.post('/appAgent/aiDialogueHistory/delMessage', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 获取打开一个新的对话的historyId
export const fetchChatOpenNewHistory = (data, config = {}) => {
  return request.post('/appAgent/aiDialogueHistory/add', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 获取所有常问问题提示词模板
export const fetchChatGuessProblem = (data, config = {}) => {
  return request.post('/appAgent/promptTemplate/getList', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 对话列表
export const fetchChatSessionList = (data, config = {}) => {
  return request.post('/appAgent/conversation/getPageList', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 新智能体列表
export const fetchChatTechnologyList = (data, config = {}) => {
  return request.post('/appAgent/aiAgent/list', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 获取智能体列表详情
export const fetchChatTechnologyDetail = (data, config = {}) => {
  return request.post('/appAgent/aiAgent/detail', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 获取默认智能体
export const fetchGetDefaultAgent = (data, config = {}) => {
  return request.post('/appAgent/aiAgent/getDidAgent', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 百度语音识别接口
export const fetchBaiduAudioRecognition = (data, config = {}) => {
  return request.post('/appAgent/aiDialogueHistory/VoiceToText', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 获取智能体详情
export const fetchGetAgentDetail = (data, config = {}) => {
  return request.post('/appAgent/aiAgent/getDetail', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 创建智能体
export const fetchCreateAgent = (data, config = {}) => {
  return request.post('/appAgent/aiAgent/create', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};

// 创建对话会话
export const fetchChatCreateSession = (data, config = {}) => {
  return request.post('/appAgent/conversation/create', data, {
    timeout: 60000,
    custom: {
      showErrorToast: true,
      ...config.custom
    },
    ...config
  });
};
